package com.ddc.study.feature.splash;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

import com.ddc.study.R;
import com.ddc.study.feature.main.MainActivity;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

/**
 * Created on 2018/3/28.
 *
 * @author lshun
 * @version 1.0
 */
public class SplashActivity extends AppCompatActivity {
    private static final long DELAY_TIME = 2500L;

    private final Handler mHandler = new Handler();
    private final Runnable mRunnable = () -> {
        startActivity(new Intent(this, MainActivity.class));
        finish();
    };

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
    }

    @Override
    protected void onStart() {
        super.onStart();
        mHandler.postDelayed(mRunnable, DELAY_TIME);
    }

    @Override
    protected void onStop() {
        super.onStop();
        mHandler.removeCallbacksAndMessages(mRunnable);
    }
}
